<template>
  <div class="container">
    <div class="screen" ref="screen">
      <Top class="top"></Top>
      <div class="bottom">
        <Tourist class="left-top">左-上</Tourist>
        <Sex class="left-center">左-中</Sex>
        <Age class="left-bottom">左-下</Age>
        <Map class="center-top">中-上</Map>
        <Line class="center-bottom">中-下</Line>
        <Rank class="right-top">右-上</Rank>
        <Year class="right-center">右-中</Year>
        <Counter class="right-bottom">右-下</Counter>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import Top from './components/top/index.vue'
import Tourist from './components/tourist/index.vue'
import Sex from './components/sex/index.vue'
import Age from './components/age/index.vue'
import Map from './components/map/index.vue'
import Line from './components/line/index.vue'
import Rank from './components/rank/index.vue'
import Year from './components/year/index.vue'
import Counter from './components/counter/index.vue'
const screen = ref()
onMounted(() => {
  setScale()
})
function getScale(w = 1920, h = 1080) {
  const ww = window.innerWidth / w
  const hh = window.innerHeight / h

  return ww < hh ? ww : hh
}
function setScale() {
  const scale = getScale()
  screen.value.style.transform = `scale(${scale}) translate(-50%,-50%)`
}
window.addEventListener('resize', () => {
  setScale()
})
</script>

<style scoped lang="scss">
.container {
  position: relative;
  width: 100vw;
  height: 100vh;
  background: url(./images/bg.png);
  background-size: cover;
  overflow: hidden;
  .screen {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 1920px;
    height: 1080px;
    transform-origin: left top;
    display: flex;
    flex-direction: column;
    color: #fff;
    .top {
      width: 100%;
      height: 40px;
    }
    .bottom {
      flex: 1;
      display: grid;
      grid-template-columns: 1fr 50% 1fr;
      grid-template-rows: 1fr 1fr 1.2fr;
      grid-auto-flow: column;
      gap: 20px;
      padding: 20px 0;
      .center-top {
        grid-row-start: span 2;
      }
    }
  }
}
</style>
